using System;
using System.Diagnostics;
using System.Xml;

namespace FreeFlow.Client
{
  /// <summary>Names of client script events.</summary>
  public static class ClientScriptEventName
  {
    /// <summary>The name of click events for buttons.</summary>
    public const string OnClick = "OnClick";
  }

	/// <summary>
	/// A client-side script call attached to a field event.
	/// </summary>
	[Serializable]
	public class ClientScriptEvent
	{
    /// <summary>
    /// Creates a new <see cref="ClientScriptEvent"/> instance.
    /// </summary>
    /// <param name="eventElement">The XML element for this client script event</param>
		public ClientScriptEvent(XmlElement eventElement)
		{
      if (eventElement != null)
      {
        eventName = eventElement.GetAttribute("Name");
        language = ClientScript.ParseLanguage(eventElement.GetAttribute("Language"));
        scriptCall = eventElement.InnerText;
      }
		}

    private string eventName;
    /// <summary>
    /// Gets the name of the event for this client script call.
    /// </summary>
    public string EventName
    {
      get
      {
        return eventName;
      }
    }

    private ClientScriptLanguage language;
    /// <summary>
    /// Gets the language of the client script call.
    /// </summary>
    public ClientScriptLanguage Language
    {
      get
      {
        return language;
      }
    }

    private string scriptCall;

    /// <summary>
    /// Gets the script that will be called.
    /// </summary>
    public string ScriptCall
    {
      get
      {
        return scriptCall;
      }
    }
	}
}
